<%--
  Created by IntelliJ IDEA.
  User: jshand
  Date: 2022-10-26
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<html>
<head>
    <title>Title</title>
    <script>
        function changeLang(sel){
            console.log(sel);
            var index = sel.selectedIndex; //选中第几个 option
            var lang = sel.options[index].value
            console.log(lang);
            window.location = "http://127.0.0.1:8080/el/jstl/fmt_bundle.jsp?lang="+lang
        }
    </script>
</head>
<body>


<select onchange="changeLang(this)">
    <option value="zh_CN"  <c:if test="${empty param.lang ||  param.lang=='zh_CN'  }">selected</c:if>    > 中文</option>
    <option value="en_US" <c:if test="${param.lang=='en_US'}">selected</c:if> >English</option>
</select>

<br>


<fmt:setLocale value="${param.lang}"/>
<fmt:setBundle basename="i18n" var="bundle"/>


<fmt:message key="input.title1" bundle="${bundle}"/>： <input type="text"> <br>
<fmt:message key="input.title2" bundle="${bundle}"/>： <input type="text"> <br>

<br>
<hr>

<fmt:bundle basename="i18n" prefix="" >

    <fmt:message key="input.title1" />： <input type="text"> <br>
    <fmt:message key="input.title2" />： <input type="text"> <br>

</fmt:bundle>


<br>
<hr>

<fmt:bundle basename="i18n" prefix="input." >

    <fmt:message key="title1" />： <input type="text"> <br>
    <fmt:message key="title2" />： <input type="text"> <br>

</fmt:bundle>





</body>
</html>
